﻿using System.ComponentModel.Composition;
using Cubicle.Core.Interfaces;

namespace Cubicle.Core.Processors.Invoke
{
    [Export("Cubicle.Processors.Invoke.FailProcessor", typeof(IProcessor<InstructionRequest>))]
    [ExportMetadata("Name", "FailProcessor")]
    [ExportMetadata("Description", "Catches failed instructions and performs error logging")]
    public class FailProcessor : InstructionRequestProcessor
    {
        private static NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();

        #region Overrides of Processor<InstructionRequest>

        public FailProcessor() : base(RequestType.Failed) { }

        public override InstructionRequest ConditionalProcess(InstructionRequest request)
        {
            _logger.Info("Instruction failed. Id={0}", request.Id);
            return request;
        }

        #endregion
    }
}